package com.zhangtong.excel.entity;

import java.math.BigDecimal;
import java.util.LinkedHashMap;
import java.util.TreeMap;

public class StatisticsData {
    private LinkedHashMap<String, StaffWorktimeData> staffStatistics;
    private LinkedHashMap<String, ProjectWorktimeData> projectStatistics;

    public StatisticsData() {
        this.staffStatistics = new LinkedHashMap<>();
        this.projectStatistics = new LinkedHashMap<>();
    }

    public void addWorktime(String name, String project, BigDecimal worktime) {
        if (!staffStatistics.containsKey(name)) {
            staffStatistics.put(name, new StaffWorktimeData(name));
        }
        staffStatistics.get(name).addWorktime(project, worktime);

        if (!projectStatistics.containsKey(project)) {
            projectStatistics.put(project, new ProjectWorktimeData(project));
        }
        projectStatistics.get(project).addWorktime(name, worktime);
    }

    public TreeMap<String, StaffWorktimeData> getStaffStatistics() {
        return new TreeMap<>(staffStatistics);
    }

    public TreeMap<String, ProjectWorktimeData> getProjectStatistics() {
        return new TreeMap<>(projectStatistics);
    }
}
